import axios from 'axios';
import {LIST_USER} from '../actions/types'

export const getListUser = (params) => {
    console.log(params)
    const URL = 'http://admin.yueduday.com/index.php?r=user';
    var page = params.page || 1;
    return (dispatch) => {
        let userData = "page=" + page + "&pageSize=20&searchText=";
        axios.get(URL,  {params: {
            'page': page,
            'pageSize': 10,
            'searchText': params.filtered
            }
        } ).then(function(response) {
            if (response.status === 200) {
                dispatch(dispatchProcess(response.data));
            }
        }).catch(function (e) {
            console.log(e)
        });
    }
}

export function dispatchProcess(info) {
    console.assert(info)
    return {
      type: LIST_USER,
      payload: info
    }
}